/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.model.objects;

/**
 * <p>This is a base class for XRESound and XREVideo. It is a simple JavaBean (POJO) that provides getters and setters
 * for all private attributes and performs no argument validation in the setters.</p>
 *
 * <p><strong>Thread safety:</strong> This class is mutable and not thread safe.</p>
 *
 * @author saarixx, jmn
 * @version 1.0
 */
public abstract class XREStreamResource extends XREResource {

    /**
     * <p>Represents the default volume value.</p>
     */
    private static final int DEFAULT_VOLUME = 100;

    /**
     * <p>The URL of the stream content.</p>
     *
     * <p>Can be any value.</p>
     *
     * <p>Has getter and setter.</p>
     */
    private String url;

    /**
     * <p>The volume level, 0 to 100. Defaults to 100.</p>
     *
     * <p>Can be any value.</p>
     *
     * <p>Has getter and setter.</p>
     */
    private int volume = DEFAULT_VOLUME;

    /**
     * <p>The value indicating whether the video will begin playing immediately after it is loaded.</p>
     *
     * <p>Can be any value.</p>
     *
     * <p>Has getter and setter.</p>
     */
    private boolean autoPlay;

    /**
     * <p>The value indicating the speed at which the stream will play. A number greater than 1 will play at fast
     * forward, a negative value should be used for fast backwards. Defaults to 1.</p>
     *
     * <p>Can be any value.</p>
     *
     * <p>Has getter and setter.</p>
     */
    private double speed = 1.0;

    /**
     * <p>The content type of the video content. This field may be used as a "hint" for the receiver.</p>
     *
     * <p>Can be any value.</p>
     *
     * <p>Has getter and setter.</p>
     */
    private String contentType;

    /**
     * <p>The current position of the playhead, in milliseconds.</p>
     *
     * <p>Can be any value.</p>
     *
     * <p>Has getter and setter.</p>
     */
    private int position;

    /**
     * <p>Creates new instance of {@link XREStreamResource} class.</p>
     */
    protected XREStreamResource() {
        // empty constructor
    }

    /**
     * <p>Retrieves the URL of the stream content.</p>
     *
     * @return the URL of the stream content
     */
    public String getUrl() {
        return url;
    }

    /**
     * <p>Sets the URL of the stream content.</p>
     *
     * @param url the URL of the stream content
     */
    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * <p>Retrieves the volume level, 0 to 100.</p>
     *
     * @return the volume level, 0 to 100
     */
    public int getVolume() {
        return volume;
    }

    /**
     * <p>Sets the volume level, 0 to 100.</p>
     *
     * @param volume the volume level, 0 to 100
     */
    public void setVolume(int volume) {
        this.volume = volume;
    }

    /**
     * <p>Retrieves the value indicating whether the video will begin playing immediately after it is loaded.</p>
     *
     * @return the value indicating whether the video will begin playing immediately after it is loaded
     */
    public boolean isAutoPlay() {
        return autoPlay;
    }

    /**
     * <p>Sets the value indicating whether the video will begin playing immediately after it is loaded.</p>
     *
     * @param autoPlay the value indicating whether the video will begin playing immediately after it is loaded
     */
    public void setAutoPlay(boolean autoPlay) {
        this.autoPlay = autoPlay;
    }

    /**
     * <p>Retrieves the value indicating the speed at which the stream will play.</p>
     *
     * @return the value indicating the speed at which the stream will play
     */
    public double getSpeed() {
        return speed;
    }

    /**
     * <p>Sets the value indicating the speed at which the stream will play.</p>
     *
     * @param speed the value indicating the speed at which the stream will play
     */
    public void setSpeed(double speed) {
        this.speed = speed;
    }

    /**
     * <p>Retrieves the content type of the video content.</p>
     *
     * @return the content type of the video content
     */
    public String getContentType() {
        return contentType;
    }

    /**
     * <p>Sets the content type of the video content.</p>
     *
     * @param contentType the content type of the video content
     */
    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    /**
     * <p>Retrieves the current position of the playhead, in milliseconds.</p>
     *
     * @return the current position of the playhead, in milliseconds
     */
    public int getPosition() {
        return position;
    }

    /**
     * <p>Sets the current position of the playhead, in milliseconds.</p>
     *
     * @param position the current position of the playhead, in milliseconds
     */
    public void setPosition(int position) {
        this.position = position;
    }
}

